package com.sc.servlet.user.field;

import com.alibaba.fastjson.JSON;
import com.sc.pojo.BookField;
import com.sc.pojo.Field;
import com.sc.services.FieldServices;
import com.sc.services.UserServices;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @description: 查找用户所有预定信息
 * @author: sc
 * @create: 2023-01-04 22:16
 **/
@WebServlet("/selectMyBookMes")
public class selectMyBookMesServlet extends HttpServlet {

    private UserServices userServices = new UserServices();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String userid = request.getParameter("userid");
        List<BookField> bookFields = userServices.selectByUserId(userid);

        String jsonString = JSON.toJSONString(bookFields);
        //3. 写数据
        response.setContentType("text/json;charset=utf-8");
        response.getWriter().write(jsonString);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}